function ajax(url, fun = function (data) {
    console.log(data)
}, type = 'GET', value) {
    if (type.toLocaleUpperCase() == 'GET') {
        let XHR = new XMLHttpRequest()
        if (value !== undefined) {
            url = url + '?' + value
        }
        console.log(url)
        XHR.open(type, 'http://localhost:8080/api/v1' + url)
        XHR.setRequestHeader('Authorization', localStorage.getItem('token'))
        XHR.send()
        XHR.onload = function () {
            fun(JSON.parse(XHR.responseText))
        }
    }
    if (type.toLocaleUpperCase() == 'POST') {
        let XHR = new XMLHttpRequest()
        XHR.open(type, 'http://localhost:8080/api/v1' + url)
        XHR.setRequestHeader('Authorization', localStorage.getItem('token'))
        XHR.setRequestHeader('Content-Type', "application/x-www-form-urlencoded")
        XHR.send(value)
        XHR.onload = function () {
            console.log(JSON.parse(XHR.responseText).msg)
            fun(JSON.parse(XHR.responseText))
        }
    }
}